from google.appengine.api import users
from google.appengine.ext import db

#App imports
import models
import budget


def GetUserEmail():
  googleUser = users.get_current_user()
  return googleUser.email()

def GetUser():
  """This checks if the current login user exists in models.User.
     If exists then set gUser Else Add the user.
  """
  googleUser = users.get_current_user()
  nickName = googleUser.nickname()
  email = googleUser.email()
  user = models.User.get_by_key_name(email)  
  if not user:
    user = models.User(key_name=email, GoogleUser=googleUser)
    user.put()  

  return user
